package server.exclusionstrategy;

import java.util.Observable;

import com.google.gson.ExclusionStrategy;
import com.google.gson.FieldAttributes;

/**
 * This class is used to exclude specific classes that cannot be modified
 * that would be serialized.
 */
public class GameExclusionStrategy implements ExclusionStrategy {

	@Override
	public boolean shouldSkipField(FieldAttributes f) {
		// Don't serialize the "obs" and "changed" fields in class Observable
		// which class Ball in the gamemodel uses.
		return (f.getDeclaringClass() == Observable.class && f.getName().equals("obs")) ||
				(f.getDeclaringClass() == Observable.class && f.getName().equals("changed"));
	}

	@Override
	public boolean shouldSkipClass(Class<?> arg) {
		return false;
	}

}
